PlotSvalbard package provides functions to plot research data from Svalbard on high resolution maps in R. The package is based on ggplot2 and the functions can be expanded using ggplot syntax. The package contains also maps from other places in the Arctic, including polar stereographic maps of the Arctic.
The maps in PlotSvalbard are designed to be printed on pdf() device. If you need the maps for other devices, see the Graphical parameters section.
The basemap function is the generic plotting command in PlotSvalbard, and is analogous to empty ggplot() call. The basemap() call plots a map that is specified by the type argument. Data containing geographic information can be plotted on these maps using the ggplot2 layers separated by the + operator.
Map types are specified by the type argument in basemap() function. The list below shows all currently implemented map types.
library(PlotSvalbard)
basemap("svalbard")
basemap("kongsfjorden") # or just basemap()
basemap("kongsfjordbotn")
basemap("kronebreen")
basemap("mosj")
basemap("barentssea")
Barents Sea map also prints mainland Norway, but the projection is not optimal, and the resolution is quite low.
basemap("barentssea", limits = c(12, 24, 68, 71))
basemap("arctic50")
basemap("arctic60")
Any basemap can be limited (or zoomed in) using the limits argument. The limits argument has to be either a numeric vector of length 4 or a character vector of length 3. Numeric vectors are used to constrain (zoom in) the maps using coordinates. Character vectors are used to automatically zoom into a dataset.
Achieved using a numeric vector. The first element defines the minimum longitude, the second element the maximum longitude, the third element the minimum latitude and the fourth element the maximum latitude of the bounding box. The coordinates have to be given as decimal degrees for Svalbard and Barents Sea maps and as UTM coordinates for pan-Arctic maps (see ?transform_coord).
basemap("svalbard", limits = c(11, 18, 77.9, 78.85)) # limits in decimal degrees
basemap("arctic50", limits = c(3*10^6, -3*10^6, 3*10^6, -3*10^6)) # limits in uTM coordinates
Note that some map types are already limited, so if you are looking for a map of Kongsfjorden, using basemap("kongsfjorden") might be just what you need.
Requires a character vector: the first element gives the object name of the data frame containing data to which the map should be limited, the second argument gives the column name of longitude data and the third argument the column name of latitude data. The map will be limited using rounded minimum and maximum floor and ceiling values for longitude and latitude. Use the limits.lon and limits.lat agruments to define the accuracy of rounding.
basemap(type = "svalbard", limits = c("kongsfjord_moorings", "Lon", "Lat"), limits.lon = 0.01, limits.lat = 0.01) + geom_point(data = kongsfjord_moorings, aes(x = lon.utm, y = lat.utm), color = "red")
All basemaps support bathymetry, but the resolution of bathymetry shapefiles is varying. Bathymetry can be plotted using the bathymetry argument.
basemap("arctic60", bathymetry = TRUE)
basemap("barentssea", bathymetry = TRUE)
The default bathymetry shapefile is too low resolution to be used inside Svalbard fjords:
basemap("kongsfjorden", bathymetry = TRUE)
PlotSvalbard contains more detailed shapefiles from the Norwegian Mapping Authority, but these files have gaps in them. More detailed shapefiles can be plotted using the bathy.detailed argument (warning: detailed bathymetries are large and therefore slow.)
basemap("kongsfjorden", bathymetry = TRUE, bathy.detailed = TRUE)
PlotSvalbard has 4 preprogrammed style alternatives:
basemap("barentssea", bathymetry = TRUE, bathy.style = "poly_blues") # default
basemap("barentssea", bathymetry = TRUE, bathy.style = "poly_greys") # grey polygons with shading
basemap("barentssea", bathymetry = TRUE, bathy.style = "contour_blues") # colored contours
basemap("barentssea", bathymetry = TRUE, bathy.style = "contour_grey") # grey contours
Adding depth labels to contours (ala nautical maps) is currently an unresolved issue.
The color scales for polygons and contours can be adjusted using ggplot2 syntax:
basemap("barentssea", bathymetry = TRUE) + scale_fill_viridis_d("Water depth (m)")
#> Scale for 'fill' is already present. Adding another scale for 'fill',
#> which will replace the existing scale.
basemap("barentssea", bathymetry = TRUE, bathy.style = "contour_blues") + scale_color_hue()
#> Scale for 'colour' is already present. Adding another scale for
#> 'colour', which will replace the existing scale.
Ocean currents for the Barents Sea have been implemented in the most recent version, but not peer-reviewed yet. This feature will be improved in the future versions of the package. Atlantic and Arctic currents are represented using red and purple arrows, respectively. The arrow color can be changed using atl.color and arc.color arguments.
basemap("barentssea", bathymetry = TRUE, bathy.style = "poly_greys", currents = TRUE, current.alpha = 0.7)
Data can be added to basemaps using the + operator and layers for ggplot2. Below you will find some examples on how to add your research data on basemaps.
Text can be added to basemaps using the geom_text() function:
data("npi_stations")
x <- transform_coord(npi_stations, lon = "Lon", lat = "Lat", bind = TRUE)
basemap("svalbard", limits = c(3,24,78.5,82), round.lat = 1, round.lon = 2,
land.col = "#a9750d", gla.border.col = "grey95") +
geom_text(data = x, aes(x = lon.utm, y = lat.utm,
label = Station), color = "red", fontface = 2)
Text size can be mapped to variables using the standard ggplot2 syntax:
data("kongsfjord_moorings")
basemap("kongsfjorden", limits = c(11.3, 12.69, 78.85, 79.1), round.lat = 0.05, round.lon = 0.5) +
geom_text(data = kongsfjord_moorings, aes(x = lon.utm, y = lat.utm,
label = Mooring.name, color = Name), fontface = 2,
size = 25.4/72.27*8) # font size = 8, see Graphical parameters